﻿using System;
using System.Linq;

namespace ChiakiYu.Common.Extensions
{
    /// <summary>
    ///     时间扩展操作类
    /// </summary>
    public static class DateTimeExtensions
    {
        /// <summary>
        ///     当前时间是否周末
        /// </summary>
        /// <param name="dateTime">时间点</param>
        /// <returns></returns>
        public static bool IsWeekend(this DateTime dateTime)
        {
            DayOfWeek[] weeks = {DayOfWeek.Saturday, DayOfWeek.Sunday};
            return weeks.Contains(dateTime.DayOfWeek);
        }

        /// <summary>
        ///     当前时间是否工作日
        /// </summary>
        /// <param name="dateTime">时间点</param>
        /// <returns></returns>
        public static bool IsWeekday(this DateTime dateTime)
        {
            DayOfWeek[] weeks =
            {
                DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday,
                DayOfWeek.Friday
            };
            return weeks.Contains(dateTime.DayOfWeek);
        }
    }
}